package lab03.test08;

import javax.swing.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.GatheringByteChannel;

public class Test {
    public static void main(String[] args) throws FileNotFoundException {

        String file1="";
        String file2="";
        String file3="";

        //字节流读文件
        FileInputStream fileInputStream=null;
        FileInputStream fileInputStream1=null;
        FileOutputStream fileOutputStream=null;
        try{
            FileInputStream file1InputStream = new FileInputStream(file1);
            FileInputStream file2InputStream = new FileInputStream(file2);

        int data1;
        int data2;
     while (((data1=file1InputStream.read())!=-1)
         ||(data2=file2InputStream.read())!=-1)
            {

     }
            GatheringByteChannel file3OutputStream = null;
            file3OutputStream.write(ByteBuffer.allocateDirect(data1));
     file3OutputStream.write(ByteBuffer.allocateDirect(data2));
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            ProgressMonitor file1OutputStream = null;
            file1OutputStream.close();
            ProgressMonitor file2OutputStream = null;
            file2OutputStream.close();
            ProgressMonitor file3OutputStream = null;
            file3OutputStream.close();


        }
        }
    }
